using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Gumps;
using Server.Commands;
using System.Collections.Generic;

namespace Server.Gumps
{
	public class InfoDifesaGump : Gump
	{
        public static void Initialize()
        {
            CommandSystem.Register("infoDifesa", AccessLevel.Player, new CommandEventHandler(InfoDifesa_OnCommand));
        }

        public InfoDifesaGump(PlayerMobile m)
			: base( 0, 0 )
		{
            BaseArmor testa = m.HeadArmor as BaseArmor;
            BaseArmor gola = m.NeckArmor as BaseArmor;
            BaseArmor corpo = m.ChestArmor as BaseArmor;
            BaseArmor braccia = m.ArmsArmor as BaseArmor;
            BaseArmor mani = m.HandArmor as BaseArmor;
            BaseArmor gambe = m.LegsArmor as BaseArmor;
            BaseArmor inguine = m.InguineArmor as BaseArmor;
            BaseArmor piedi = m.FeetArmor as BaseArmor;
			this.Closable=true;
			this.Disposable=true;
			this.Dragable=true;
			this.Resizable=false;
			this.AddPage(0);
			this.AddBackground(0, 0, 257, 514, 9200);
			this.AddLabel(20, 10, 0x480, @"Testa");
			this.AddLabel(20, 32, 0x480, @"Gola");
			this.AddLabel(20, 53, 0x480, @"Corpo");
			this.AddLabel(20, 74, 0x480, @"Braccia");
			this.AddLabel(20, 94, 0x480, @"Mani");
			this.AddLabel(20, 113, 0x480, @"Gambe");
			this.AddLabel(20, 133, 0x480, @"Inguine");
			this.AddLabel(20, 153, 0x480, @"Piedi");
			this.AddLabel(20, 171, 0x480, @"Difese Generali");
			this.AddLabel(20, 191, 0x480, @"Percent. Parata");
			this.AddLabel(20, 210, 0x480, @"Danni Parabili");
			this.AddLabel(20, 229, 0x480, @"Schivare Base");
			this.AddLabel(20, 249, 0x480, @"Freddo");
			this.AddLabel(20, 269, 0x480, @"Fuoco");
			this.AddLabel(20, 289, 0x480, @"Acido");
			this.AddLabel(20, 310, 0x480, @"Veleno");
			this.AddLabel(20, 330, 0x480, @"Malattia");
			this.AddLabel(20, 349, 0x480, @"Elettricita");
			this.AddLabel(20, 367, 0x480, @"Energia");
			this.AddLabel(20, 387, 0x480, @"Paralisi");
			this.AddLabel(20, 408, 0x480, @"Fisici");
			this.AddLabel(20, 427, 0x480, @"D.Ritornato");
			this.AddLabel(20, 446, 0x480, @"D.Ridotto");
			this.AddLabel(20, 466, 0x480, @"D.Amplificato");
            if (testa != null)
                this.AddLabel(160, 11, 0x480, String.Format("{0}+{1}", testa.BaseArmorRating, testa.MagicBonus));
            else
                this.AddLabel(160, 11, 0x480, @"0+0");
            if (gola != null)
                this.AddLabel(160, 31, 0x480, String.Format("{0}+{1}", gola.BaseArmorRating, gola.MagicBonus));
            else
                this.AddLabel(160, 31, 0x480, @"0+0");
            if (corpo != null)
                this.AddLabel(160, 51, 0x480, String.Format("{0}+{1}", corpo.BaseArmorRating, corpo.MagicBonus));
            else
                this.AddLabel(160, 51, 0x480, @"0+0");
            if (braccia != null)
                this.AddLabel(160, 71, 0x480, String.Format("{0}+{1}", braccia.BaseArmorRating, braccia.MagicBonus));
            else
                this.AddLabel(160, 71, 0x480, @"0+0");
            if (mani != null)
                this.AddLabel(160, 91, 0x480, String.Format("{0}+{1}", mani.BaseArmorRating, mani.MagicBonus));
            else
                this.AddLabel(160, 91, 0x480, @"0+0");
            if (gambe != null)
                this.AddLabel(160, 111, 0x480, String.Format("{0}+{1}", gambe.BaseArmorRating, gambe.MagicBonus));
            else
                this.AddLabel(160, 111, 0x480, @"0+0");
            if (inguine != null)
                this.AddLabel(160, 131, 0x480, String.Format("{0}+{1}", inguine.BaseArmorRating, inguine.MagicBonus));
            else
                this.AddLabel(160, 131, 0x480, @"0+0");
            if (piedi != null)
                this.AddLabel(160, 152, 0x480, String.Format("{0}+{1}", piedi.BaseArmorRating, piedi.MagicBonus));
            else
                this.AddLabel(160, 152, 0x480, @"0+0");

			this.AddLabel(160, 171, 0x480, String.Format("{0}", m.Difesa));

			this.AddLabel(160, 191, 0x480, @"_TODO_");

            BaseShield scudo = m.FindItemOnLayer(Layer.TwoHanded) as BaseShield;
            if (scudo != null) {
                double parry = m.Skills[SkillName.Parry].Value;
                this.AddLabel(160, 211, 0x480, String.Format("{0}", scudo.BaseArmorRating / 2 + scudo.MagicBonus + ((int)Math.Round(parry))/16)); // qui sarebbe rand(10,22), prendiamo il valore medio
			} 
            else
                this.AddLabel(160, 211, 0x480, @"0");

             this.AddLabel(160, 231, 0x480, String.Format("{0}%", m.Schivare));

             this.AddLabel(160, 251, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Cold)));
             this.AddLabel(160, 270, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Fire)));
             this.AddLabel(160, 290, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Acido)));
             this.AddLabel(160, 309, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Poison)));
            this.AddLabel(160, 328, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Malattia)));
            this.AddLabel(160, 348, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Elettricita)));
            this.AddLabel(160, 366, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Energy)));
            this.AddLabel(160, 387, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Paralisi)));
            this.AddLabel(160, 408, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.Physical)));
            this.AddLabel(160, 427, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.DannoRitornato)));
            this.AddLabel(160, 446, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.DannoRidotto)));
            this.AddLabel(160, 467, 0x480, String.Format("{0}%", m.GetResistance(ResistanceType.DannoAmplificato)));
		}


        private static void InfoDifesa_OnCommand(CommandEventArgs e)
        {
            e.Mobile.SendGump(new InfoDifesaGump(e.Mobile as PlayerMobile));
        }
	}
}